package leetcode战队赛;

public class One {
	
	public static void main(String args[]) {
		int time[] = {2,3,2}; 
				int fruit[][]  = {{0,2},{1,4},{2,1}}; 
						int limit = 3;
		System.out.println(solution(time,fruit,limit));
	}
	public static int solution(int time[] ,int  fruit[][],int limit) {
		int ans = 0;
		for(int  i = 0;i < fruit.length;i++) {
			int type  = fruit[i][0];
			int num = fruit[i][1];
			int temp = 0;
			if(num % limit == 0) {
				temp = num /limit;
			}
			else
				temp =num/limit + 1;
			ans +=time[type] * temp;
		}
		
		return ans;
	}

}
